#include "microbe.h"

////////////////////////////////////////////////////////////////////////////////

bool Microbe_canSoldierAttack(const Microbe* microbe, const Food* food)
{
  Vector2 dir;
  LineSegment ls;
  Circle food_circle;
  
  Vector2_fromAngle(&dir, microbe->angle);
  
  ls.p1 = microbe->body.pos;
  ls.p2 = microbe->body.pos + SOLDIER_MICROBE_SIGHT_RADIUS * dir;
  
  food_circle.pos = food->pos;
  food_circle.radius = SIM_FOOD_RADIUS;
  
  return food_circle.intersect(ls);
}

bool Microbe_canSoldierAttack(const Microbe* microbe, const Microbe* enemy)
{
  Vector2 dir;
  LineSegment ls;
  
  Vector2_fromAngle(&dir, microbe->angle);
  
  ls.p1 = microbe->body.pos;
  ls.p2 = microbe->body.pos + SOLDIER_MICROBE_SIGHT_RADIUS * dir;
  
  return enemy->body.intersect(ls);
}
